<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>prepiano</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="prealloc.html" title="prealloc" />
    <link rel="next" href="print.html" title="print" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">prepiano</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="prealloc.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="print.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="prepiano"></a>
      <div class="titlepage"></div>
      <a id="IndexPrepiano" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">prepiano</span>
        </h2>
        <p>prepiano — 
      Creates a tone similar to a piano string prepared in a Cageian fashion.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp135664784"></a>
        <h2>Description</h2>
        <p>
      Audio output is a tone similar to a piano string, prepared with
    a number of rubbers and rattles. The method uses a
    physical model developed from solving the partial differential
    equation.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp135666160"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>prepiano</strong></span> ifreq, iNS, iD, iK, \
    iT30,iB, kbcl, kbcr, imass, ihvfreq, iinit, ipos, ivel, isfreq, \
    isspread[, irattles, irubbers]</pre>
        <pre class="synopsis">al,ar <span class="command"><strong>prepiano</strong></span> ifreq, iNS, iD, iK, \
    iT30,iB, kbcl, kbcr, imass, ihvfreq, iinit, ipos, ivel, isfreq, \
    isspread[, irattles, irubbers]</pre>
      </div>
      <div class="refsect1">
        <a id="idp135669872"></a>
        <h2>Initialization</h2>
        <p>
    <span class="emphasis"><em>ifreq</em></span> -- The base frequency of the string.
    </p>
        <p>
    <span class="emphasis"><em>iNS</em></span> -- the number of strings involved.  In a
    real piano 1, 2 or 3 strings are found in different frequency regions.
    </p>
        <p>
    <span class="emphasis"><em>iD</em></span> -- the amount each string other that the
    first is detuned from the main frequency, measured in cents.
    </p>
        <p>
    <span class="emphasis"><em>iK</em></span> -- dimensionless stiffness parameter.
    </p>
        <p>
    <span class="emphasis"><em>iT30</em></span> -- 30 db decay time in seconds.
    </p>
        <p>
    <span class="emphasis"><em>ib</em></span> -- high-frequency loss parameter (keep this small).
    </p>
        <p>
    <span class="emphasis"><em>imass</em></span> -- the mass of the piano hammer.
    </p>
        <p>
    <span class="emphasis"><em>ihvfreq</em></span> -- the frequency of the natural
    vibrations of the hammer.
    </p>
        <p>
    <span class="emphasis"><em>iinit</em></span> -- the initial position of the hammer.
    </p>
        <p>
    <span class="emphasis"><em>ipos</em></span> -- position along the string that the strike occurs.
    </p>
        <p>
    <span class="emphasis"><em>ivel</em></span> -- normalized strike velocity.
    </p>
        <p>
    <span class="emphasis"><em>isfreq</em></span> -- scanning frequency of the reading place.
    </p>
        <p>
    <span class="emphasis"><em>isspread</em></span> -- scanning frequency spread.
    </p>
        <p>
    <span class="emphasis"><em>irattles</em></span> -- table number giving locations of
    any rattle(s).
    </p>
        <p>
    <span class="emphasis"><em>irubbers</em></span> -- table number giving locations of
    any rubbers(s).
    </p>
        <p>
      The rattles and rubbers tables are collections of four values,
      preceeded by a count.
      In the case of a rattle the four are position, mass density
      ratio of rattle/string,
      frequency of rattle and vertical length of the rattle.  For the
      rubber the fours are position, mass density ratio of
      rubber/string, frequency of rubber and the loss parameter.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp135684432"></a>
        <h2>Performance</h2>
        <p>
      A note is played on a piano string, with the arguments as below.
    </p>
        <p>
      <span class="emphasis"><em>kbcL</em></span> -- Boundary condition at left end of
    string (1 is clamped, 2 pivoting and 3 free).
    </p>
        <p>
      <span class="emphasis"><em>kbcR</em></span> -- Boundary condition at right end of
    string (1 is clamped, 2 pivoting and 3 free).
    </p>
        <p>
      Note that changing the boundary conditions during playing may
  lead to glitches and is made available as an experiment.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp135688064"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the prepiano opcode. It uses the file <a class="ulink" href="examples/prepiano.csd" target="_top"><em class="citetitle">prepiano.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp135689920"></a>
          <p class="title">
            <strong>Example 648. Example of the prepiano opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if real audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o prepiano.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span> 1
<span class="comment">;;          fund NS detune stiffness decay loss (bndry) (hammer) scan prep</span>
aa,ab <span class="opc">prepiano</span> 60, 3, 10, p4, 3, 0.002, 2, 2, 1, 5000, <span class="op">-</span>0.01, p5, p6, 0, 0.1, 1, 2
      <span class="opc">outs</span> aa<span class="op">*</span>.2, ab<span class="op">*</span>.2

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span>1 0 8 2 1 0.6 10 100 0.001 <span class="comment">;; 1 rattle</span>
<span class="stamnt">f</span>2 0 8 2 1 0.7 50 500 1000  <span class="comment">;; 1 rubber</span>
<span class="stamnt">i</span>1 0.0 1 1 0.09 20
<span class="stamnt">i</span>1 1 .  -1 0.09 40        <span class="comment">;; 1 -&gt; skip initialisation</span>
<span class="stamnt">i</span>1 2 .  -1 0.09 60
<span class="stamnt">i</span>1 3 .  -1 0.09 80
<span class="stamnt">i</span>1 4 1.8  -1 0.09 100
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp135694208"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Stefan Bilbao </td>
          </tr>
          <tr>
            <td>University of Edinburgh, UK</td>
          </tr>
          <tr>
            <td>Author: John ffitch </td>
          </tr>
          <tr>
            <td>University of Bath, Codemist Ltd.</td>
          </tr>
          <tr>
            <td>Bath, UK</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 5.05</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="prealloc.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="print.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">prealloc </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> print</td>
        </tr>
      </table>
    </div>
  </body>
</html>
